From 3b17e1a5e922889e35d36ded3b58d88b3817ac71 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Wed, 14 May 2008 14:12:53 +0100 Subject: [PATCH] x86: Make MSI-X work with 64-bit BARs The code for working out the base address of a 64-bit BAR currently puts the two halves together in the wrong order and leaves the type bits in the resulting value. It also treats PCI_BASE_ADDRESS_MEM_TYPE_64 as a flag rather than an enumeration value. Signed-off-by: Neil Turton --- xen/arch/x86/msi.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/msi.c b/xen/arch/x86/msi.c index bee19a2963..37d7914841 100644 --- a/xen/arch/x86/msi.c +++ b/xen/arch/x86/msi.c @@ -521,17 +521,20 @@ static int msi_capability_init(struct pci_dev *dev, int vector) static u64 pci_resource_start(struct pci_dev *dev, u8 bar_index) { u64 bar_base; + u32 reg_val; u8 bus = dev->bus; u8 slot = PCI_SLOT(dev->devfn); u8 func = PCI_FUNC(dev->devfn); - bar_base = pci_conf_read32(bus, slot, func, - PCI_BASE_ADDRESS_0 + 4 * bar_index); - if ( bar_base & PCI_BASE_ADDRESS_MEM_TYPE_64 ) + reg_val = pci_conf_read32(bus, slot, func, + PCI_BASE_ADDRESS_0 + 4 * bar_index); + bar_base = reg_val & PCI_BASE_ADDRESS_MEM_MASK; + if ( ( reg_val & PCI_BASE_ADDRESS_MEM_TYPE_MASK ) == + PCI_BASE_ADDRESS_MEM_TYPE_64 ) { - bar_base <<= 32; - bar_base += pci_conf_read32(bus, slot, func, - PCI_BASE_ADDRESS_0 + 4 * (bar_index + 1)); + reg_val = pci_conf_read32(bus, slot, func, + PCI_BASE_ADDRESS_0 + 4 * (bar_index + 1)); + bar_base |= ((u64)reg_val) << 32; } return bar_base; -- 2.30.2